package com.guanyong.services;

import com.guanyong.dao.KeyBaseDaoMapper;
import com.guanyong.dao.KeyBaseJavaDaoMapper;
import com.guanyong.model.*;
import com.guanyong.utils.Comm.ResultCode;
import com.guanyong.utils.Comm.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by mxk on 2017/7/3.
 */
@Service
public class KeybaseJavaService {

   @Autowired
   KeyBaseJavaDaoMapper keyBaseJavaDaoMapper;



   public List<KeyJavaZhishuModel> getZhishuAll() {
      return keyBaseJavaDaoMapper.selectAll();
   }

   public ResultObject<Integer> updateById(KeyJavaZhishuModel keyJavaZhishuModel) {
      ResultObject<Integer> resultObject=new ResultObject<Integer>();
      Integer res= keyBaseJavaDaoMapper.updateById(keyJavaZhishuModel);
      if (res >-1){
         resultObject.setCode(ResultCode.OperateOk);
      }
      else{
         resultObject.setCode(ResultCode.OperateFail);
      }
      return resultObject;
   }

   public ResultObject<Integer> AddZhishu(KeyJavaZhishuModel keyJavaZhishuModel) {
      ResultObject<Integer> resultObject=new ResultObject<Integer>();
      Integer res= keyBaseJavaDaoMapper.addZhishu(keyJavaZhishuModel);
      if (res >-1){
         resultObject.setCode(ResultCode.OperateOk);
      }
      else{
         resultObject.setCode(ResultCode.OperateFail);
      }
      return resultObject;
   }

    public ResultObject<Integer> delById(int id) {
       ResultObject<Integer> resultObject=new ResultObject<Integer>();
       Integer res= keyBaseJavaDaoMapper.delById(id);
       if (res >-1){
          resultObject.setCode(ResultCode.OperateOk);
       }
       else{
          resultObject.setCode(ResultCode.OperateFail);
       }
       return resultObject;
    }
}
